package com.cntcdt.api.db.dao;

import java.util.List;

import com.cntcdt.api.db.dao.base.DeviceMoveApplyDaoBase;
import com.cntcdt.api.db.model.DeviceMoveApplyModel;

/**
 * 这是device_move_apply的Dao实现类
 */
public class DeviceMoveApplyDao extends DeviceMoveApplyDaoBase   {
    /**
     * DeviceMoveApplyDao对象
     */
    private static DeviceMoveApplyDao instance = new DeviceMoveApplyDao();

    /**
     * 默认构造方法
     */
    private DeviceMoveApplyDao() {
    }

    /**
     * 获得对象实例
     */
    public static DeviceMoveApplyDao getInstance() { 
         return instance;
    } 
    
    public List<DeviceMoveApplyModel> findBySortTime(int userId,int type,int sortTime) {
    	sortTime = sortTime*20;
        String sql = "SELECT * FROM " + TABLE + " WHERE type = ? and userId = ? order by addTime desc limit ?,20";
       Object[] paramObjs = {type,sortTime};
       List<DeviceMoveApplyModel> modelList = this.queryModelList(sql, paramObjs);
       return modelList;
   }
    
    public List<DeviceMoveApplyModel> findBySortTime(int userId,int sortTime) {
    	sortTime = sortTime*20;
        String sql = "SELECT * FROM " + TABLE + " WHERE userId = ? order by addTime desc limit ?,20";
       Object[] paramObjs = {userId,sortTime};
       List<DeviceMoveApplyModel> modelList = this.queryModelList(sql, paramObjs);
       return modelList;
   }    
    
    public List<DeviceMoveApplyModel> findBySortTime(int sortTime) {
    	sortTime = sortTime*20;
        String sql = "SELECT * FROM " + TABLE + " order by isDispose,updateTime desc limit ?,20";
       Object[] paramObjs = {sortTime};
       List<DeviceMoveApplyModel> modelList = this.queryModelList(sql, paramObjs);
       return modelList;
   }    
    
    public List<DeviceMoveApplyModel> findBySearchContent(String searchContent) {
        String sql = "select * from " + TABLE + " where terminal like ? or address like ? or name like ? or userId in (select id from admin_user where name like ?)";
       Object[] paramObjs = {searchContent,searchContent,searchContent,searchContent};
       List<DeviceMoveApplyModel> modelList = this.queryModelList(sql, paramObjs);
       return modelList;
   }    
}
